#include "widget.h"
#include "ui_widget.h"
#include <QPainter>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
//    painter.translate(80,80);
    painter.drawPixmap(QRect(0,0,300,300),QPixmap(":/backImage.png"));

    //从400，400开始画，
    painter.drawPixmap(400,400,50,60,QPixmap(":/backImage.png"));
}

//void Widget::paintEvent(QPaintEvent *event)
//{
//    //实例化Painter对象
//    //this表示的是在当前窗口中绘画（最终把像素画到QWidget上，即绘图设备）
//    QPainter painter(this);

////    QPen pen(QColor(255,0,0));
////    //设置画笔宽度与风格
////    pen.setWidth(3);
////    pen.setStyle(Qt::DotLine);
////    //让画家使用画笔
////    painter.setPen(pen);

////    QBrush brush(Qt::Dense5Pattern);
////    brush.setColor(QColor(Qt::green));
////    painter.setBrush(brush);
////    painter.drawEllipse(QPoint(300,300),150,100);
////    QFont font("华文行楷",24);
////    painter.setFont(font);
////    painter.drawText(QRect(100,200,500,200),"勤能补拙");

////    painter.drawEllipse(QPoint(300,300),150,100);
////    painter.drawRect(20,20,400,200);
////    painter.drawLine(QPoint(20,200),QPoint(600,200));
//}

